/*
 * This file is part of ksPlatform
 * 
 * Copyright (c) 2014-2015
 * 
 * This file is dual-licensed under the AGPLv3 (http://www.gnu.org/licenses/agpl-3.0.html) 
 * 
 * If you are unsure which license is appropriate for your use, please contact the sales department
 * at 97041437@qq.com.
 */

package cn.com.ksplatform.modules.system.auth.usermanager.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonIgnore;
import org.hibernate.annotations.GenericGenerator;

import cn.com.ksplatform.base.BaseModel;
import cn.com.ksplatform.modules.system.auth.orgmanager.model.PlatStation;
import cn.com.ksplatform.modules.system.auth.rolemanager.model.PlatRole;

/**
 * ClassName:PlatUser <br/>
 * Date: 2015年5月8日 下午4:32:40 <br/>
 * 
 * @author Mr.Luoxing
 * @version 1.0
 */

@Entity
@Table(name = "t_sys_user")
public class PlatUser extends BaseModel {

	@Id
	@GenericGenerator(name = "systemUUID", strategy = "uuid")
	@GeneratedValue(generator = "systemUUID")
	@Column(name = "userId")
	private String userId;// 唯一标示
	@Column(unique=true)
	private String userName;// 用户名
	private String passWord;// 用户密码
	private String enabled;//
	private String other;// 其他信息使用json格式保存数据

	@JsonIgnore
	@ManyToMany
	@JoinTable(name = "t_sys_user_role", joinColumns = @JoinColumn(name = "userId"), inverseJoinColumns = @JoinColumn(name = "roleId"))
	private Set<PlatRole> roles = new HashSet<PlatRole>();

	/*@JsonIgnore
	@ManyToMany(fetch = FetchType.LAZY, cascade = { CascadeType.MERGE, CascadeType.PERSIST })
	@JoinTable(name = "t_sys_user_station", joinColumns = @JoinColumn(name = "userId"), inverseJoinColumns = @JoinColumn(name = "staId"))*/
	@JsonIgnore
	@ManyToMany(mappedBy="users",fetch=FetchType.LAZY)
	private Set<PlatStation> stations = new HashSet<PlatStation>();

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPassWord() {
		return passWord;
	}

	public void setPassWord(String passWord) {
		this.passWord = passWord;
	}

	public String getOther() {
		return other;
	}

	public void setOther(String other) {
		this.other = other;
	}

	public Set<PlatStation> getStations() {
		return stations;
	}

	public void setStations(Set<PlatStation> stations) {
		this.stations = stations;
	}

	public Set<PlatRole> getRoles() {
		return roles;
	}

	public void setRoles(Set<PlatRole> roles) {
		this.roles = roles;
	}

	public String getEnabled() {
		return enabled;
	}

	public void setEnabled(String enabled) {
		this.enabled = enabled;
	}
}
